-module (add_one).
-export ([start/0, request/1, loop/0]).

start() ->
	io:format("start add_one : ~p~n", [self()]),
	register(add_one,spawn_link(add_one, loop, [])).

request(Int) ->
	add_one ! {request, self(), Int},
	receive
		{result, Result} ->
			Result
	after 1000 -> timeout
	end.

loop() ->
	receive
		{request, Pid, Msg} ->
			io:format("start add_one : ~p | ~p~n", [Pid, Msg]),
			Pid ! {result, Msg+1}
	end,
	loop().
